/**
 * @author chenjian2@staff.sina.com.cn
 */
$Import('app.common.getElement');
STK.register('app.ui.tree', function($){
	return function(node,opts){
		var that	= {},dEvent,selectedNode;
			opts = $.parseParam({
				data: []
			}, opts);
		var itemTemple = $.core.util.easyTemplate(
		'<#et list gList>'+
			'<#list gList as item>'+
				'<li action-type="item" action-data="type=${item.type}&path=${item.path}" class="m-collapsed">'+
					'<span>${item.name}</span>'+
			'</#list>'+
		'</#et>');
		var bindDOMFuns = {
			
		};
		var delegatedEvent = {

		};
		var bindDOM = function(){
			
		};
		
		var argsCheck = function(){
			if (!$.core.dom.isNode(node)) {
				throw "[STK.ui.tree]:node is not a Node!";
			}
		};
		var parseDOM = function(){
			var html = itemTemple(opts.data).toString();
			node.innerHTML = html;
		};
		
		var bindListener = function(){
			var cEvt = $.custEvent.define(node, ['onSelect']);
		};
		
		var destroy = function(){
			bindDOMFuns = null;
		};
		var init = function(){
			argsCheck();
			parseDOM();
			bindDOM();
			bindListener();
		};
		init();
		that.destroy = destroy;
		return that;

	};
});